/**
 * api 接口统一管理
 */

import service from "./http"

// 登录
export const login = (data: object) => service.post("/login", data)
// 获取用户信息
export const userInfo = () => service.get("/user-info")

// api管理
export const systemApi = {
    store: (data: object) => service.post("/system/api", data), // 新增
    list: (data: object) => service.get("/system/api", {params: data}), // 列表
    delete: (ids: string) => service.post("/system/api/delete", {ids}), // 删除
    find: (id: number) => service.get(`/system/api/${id}`), // 详情
    update: (data: object) => service.put("/system/api", data), // 修改
    groupInfo: () => service.get("/system/api/group"), // 分组信息
}

// 菜单管理
export const systemMenu = {
    store: (data: object) => service.post("/system/menu", data), // 新增
    list: () => service.get("/system/menu"), // 列表
    delete: (id: string) => service.post("/system/menu/delete", {id}), // 删除
    update: (data: object) => service.put("/system/menu", data), // 修改
    apis: () => service.get(`/system/menu/api`), // api数据
}

// 角色管理
export const systemRole = {
    store: (data: object) => service.post("/system/role", data), // 新增
    list: (data: object) => service.get("/system/role", {params: data}), // 列表
    delete: (ids: string) => service.post("/system/role/delete", {ids}), // 删除
    update: (data: object) => service.put("/system/role", data), // 修改
    find: (id: number) => service.get(`/system/role/${id}`), // 详情
}

// 管理员管理
export const systemAdmin = {
    store: (data: object) => service.post("/system/admin", data), // 新增
    list: (data: object) => service.get("/system/admin", {params: data}), // 列表
    delete: (ids: string) => service.post("/system/admin/delete", {ids}), // 删除
    update: (data: object) => service.put("/system/admin", data), // 修改
    find: (id: number) => service.get(`/system/admin/${id}`), // 详情
    roles: () => service.get(`/system/admin/role`), // 角色数据
}

// 文件分组
export const fileLibraryGroup = {
    store: (data: object) => service.post("/file-library/group", data), // 新增
    list: (data: object) => service.get("/file-library/group", {params: data}), // 列表
    delete: (ids: string) => service.post("/file-library/group/delete", {ids}), // 删除
    update: (data: object) => service.put("/file-library/group", data), // 修改
    find: (id: number) => service.get(`/file-library/group/${id}`), // 详情
}

// 文件
export const fileLibrary = {
    uploadAction: import.meta.env.VITE_BASE_URL + "/file-library/upload", // 上传地址
    list: (data: object) => service.get("/file-library", {params: data}), // 列表
}
